package jmvm.schemes;


import java.awt.Point;
import java.util.ArrayList;

import jmvm.components.*;
import jmvm.gui.GuiLabel;
import jmvm.gui.GuiLine;
import jmvm.gui.GuiScheme;



public class Exec2 {
	
	public static IntToBools IBUSBits;		// Bitovi sa magistrale
	
	public static AND IAND1;
	public static OR IOR1;
	public static AND IAND2;
	public static OR IOR2;
	public static NOT INOT;
	public static RSFF IRSFF;

	public static AND TAND1;
	public static OR TOR1;
	public static AND TAND2;
	public static OR TOR2;
	public static NOT TNOT;
	public static RSFF TRSFF;

	public static AND NAND1;
	public static AND NAND2;
	public static OR NOR1;
	public static NOT NNOT1;
	public static AND NAND3;
	public static NOT NNOT2;
	public static AND NAND4;
	public static OR NOR2;
	public static RSFF NRSFF;

	public static AND ZAND1;
	public static AND ZAND2;
	public static OR ZOR1;
	public static NOT ZNOT1;
	public static AND ZAND3;
	public static NOT ZNOT2;
	public static AND ZAND4;
	public static OR ZOR2;
	public static RSFF ZRSFF;

	public static AND CAND1;
	public static AND CAND2;
	public static OR COR1;
	public static NOT CNOT1;
	public static AND CAND3;
	public static NOT CNOT2;
	public static AND CAND4;
	public static OR COR2;
	public static RSFF CRSFF;

	public static AND VAND1;
	public static AND VAND2;
	public static OR VOR1;
	public static NOT VNOT1;
	public static AND VAND3;
	public static NOT VNOT2;
	public static AND VAND4;
	public static OR VOR2;
	public static RSFF VRSFF;

	public static AND L0AND1;
	public static AND L0AND2;
	public static OR L0OR1;
	public static NOT L0NOT1;
	public static AND L0AND3;
	public static NOT L0NOT2;
	public static AND L0AND4;
	public static OR L0OR2;
	public static RSFF L0RSFF;

	public static AND L1AND1;
	public static AND L1AND2;
	public static OR L1OR1;
	public static NOT L1NOT1;
	public static AND L1AND3;
	public static NOT L1NOT2;
	public static AND L1AND4;
	public static OR L1OR2;
	public static RSFF L1RSFF;
	
	// DODATO
	public static AND L2AND1;
	public static AND L2AND2;
	public static OR L2OR1;
	public static NOT L2NOT1;
	public static AND L2AND3;
	public static NOT L2NOT2;
	public static AND L2AND4;
	public static OR L2OR2;
	public static RSFF L2RSFF;

	// IZMENJENO
	public static BoolsToInt PSW_H, PSW_L;
	public static TSB PSWHout, PSWLout;

	public static RSFF STARTRSFF;
	public static NOT not_start;

	////////////
	//////////// Grafika
	////////////
	
	public static GuiScheme gui;

	public static GuiScheme getGui() {
		return gui;
	}
	
	public static void gui() {

		GuiLine line; // Pomocna promenljiva
		gui = new GuiScheme("jmvm/jmvm/images/exec2.png");
		
		ArrayList<ArrayList<Point>> sections;
		ArrayList<Point> points;
		
		// 
		// 
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(59,23));
		points.add(new Point(59,200));
		points.add(new Point(65,200));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWH());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(60,161));
		points.add(new Point(65,161));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWH());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(60,94));
		points.add(new Point(65,94));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWH());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(60,56));
		points.add(new Point(65,56));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWH());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(132,51));
		points.add(new Point(136,51));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.stPSWI());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(132,111));
		points.add(new Point(136,111));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.clPSWI());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(132,156));
		points.add(new Point(137,156));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.stPSWT());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(132,216));
		points.add(new Point(136,216));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.clPSWT());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(4,2));
		points.add(new Point(4,274));
		sections.add(points);
		line=new GuiLine(sections,Bus.IBUS());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(5,247));
		points.add(new Point(265,247));
		sections.add(points);
		line=new GuiLine(sections,Bus.IBUS());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(266,2));
		points.add(new Point(266,760));
		points.add(new Point(268,760));
		points.add(new Point(268,2));
		sections.add(points);
		line=new GuiLine(sections,Bus.IBUS());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(5,105));
		points.add(new Point(61,105));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(7));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(52,104));
		points.add(new Point(52,66));
		points.add(new Point(65,66));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(7));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(5,211));
		points.add(new Point(61,211));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(6));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(52,210));
		points.add(new Point(52,172));
		points.add(new Point(65,172));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(6));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(88,61));
		points.add(new Point(136,61));
		sections.add(points);
		line=new GuiLine(sections,IAND1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(88,100));
		points.add(new Point(136,100));
		sections.add(points);
		line=new GuiLine(sections,IAND2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(88,167));
		points.add(new Point(136,167));
		sections.add(points);
		line=new GuiLine(sections,TAND1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(88,205));
		points.add(new Point(136,205));
		sections.add(points);
		line=new GuiLine(sections,TAND2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(157,56));
		points.add(new Point(162,56));
		sections.add(points);
		line=new GuiLine(sections,IOR1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(157,105));
		points.add(new Point(162,105));
		sections.add(points);
		line=new GuiLine(sections,IOR2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(157,161));
		points.add(new Point(162,161));
		sections.add(points);
		line=new GuiLine(sections,TOR1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(157,211));
		points.add(new Point(162,211));
		sections.add(points);
		line=new GuiLine(sections,TOR2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(216,56));
		points.add(new Point(223,56));
		sections.add(points);
		line=new GuiLine(sections,IRSFF.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(216,161));
		points.add(new Point(222,161));
		sections.add(points);
		line=new GuiLine(sections,TRSFF.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(114,448));
		points.add(new Point(171,448));
		sections.add(points);
		line=new GuiLine(sections,PSW_H.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(114,579));
		points.add(new Point(171,579));
		sections.add(points);
		line=new GuiLine(sections,PSW_L.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(193,448));
		points.add(new Point(266,448));
		sections.add(points);
		line=new GuiLine(sections,PSWHout.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(193,579));
		points.add(new Point(266,579));
		sections.add(points);
		line=new GuiLine(sections,PSWLout.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(182,458));
		points.add(new Point(182,453));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.PSWHout());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(182,590));
		points.add(new Point(182,584));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.PSWLout());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(164,688));
		points.add(new Point(170,688));
		sections.add(points);
		line=new GuiLine(sections,STARTRSFF.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(104,688));
		points.add(new Point(110,688));
		sections.add(points);
		line=new GuiLine(sections,new Pin(false));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(104,738));
		points.add(new Point(110,738));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.clSTART());
		gui.addLine(line);

		//
		//
		// 
		// 
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,42));
		points.add(new Point(374,42));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldN());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(368,43));
		points.add(new Point(368,109));
		points.add(new Point(374,109));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldN());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,81));
		points.add(new Point(361,81));
		points.add(new Point(361,53));
		points.add(new Point(374,53));
		sections.add(points);
		line=new GuiLine(sections,Exec3.N());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(361,82));
		points.add(new Point(361,119));
		points.add(new Point(369,119));
		sections.add(points);
		line=new GuiLine(sections,Exec3.N());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(268,105));
		points.add(new Point(328,105));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(319,104));
		points.add(new Point(319,67));
		points.add(new Point(332,67));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,61));
		points.add(new Point(403,61));
		sections.add(points);
		line=new GuiLine(sections,NAND1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(397,47));
		points.add(new Point(399,47));
		points.add(new Point(399,51));
		points.add(new Point(403,51));
		sections.add(points);
		line=new GuiLine(sections,NAND2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,100));
		points.add(new Point(403,100));
		sections.add(points);
		line=new GuiLine(sections,NAND3.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(396,114));
		points.add(new Point(399,114));
		points.add(new Point(399,111));
		points.add(new Point(403,111));
		sections.add(points);
		line=new GuiLine(sections,NAND4.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,56));
		points.add(new Point(429,56));
		sections.add(points);
		line=new GuiLine(sections,NOR1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,105));
		points.add(new Point(429,105));
		sections.add(points);
		line=new GuiLine(sections,NOR2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(483,56));
		points.add(new Point(490,56));
		sections.add(points);
		line=new GuiLine(sections,NRSFF.getOut(0));
		gui.addLine(line);

		//////////////////////////////////////////////////////////////////////////////////////////////////
		
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,42+105));
		points.add(new Point(374,42+105));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldZ());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(368,43+105));
		points.add(new Point(368,109+105));
		points.add(new Point(374,109+105));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldZ());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,81+105));
		points.add(new Point(361,81+105));
		points.add(new Point(361,53+105));
		points.add(new Point(374,53+105));
		sections.add(points);
		line=new GuiLine(sections,Exec3.Z());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(361,82+105));
		points.add(new Point(361,119+105));
		points.add(new Point(369,119+105));
		sections.add(points);
		line=new GuiLine(sections,Exec3.Z());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(268,105+105));
		points.add(new Point(328,105+105));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(1));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(319,104+105));
		points.add(new Point(319,67+105));
		points.add(new Point(332,67+105));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(1));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,61+105));
		points.add(new Point(403,61+105));
		sections.add(points);
		line=new GuiLine(sections,ZAND1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(397,47+105));
		points.add(new Point(399,47+105));
		points.add(new Point(399,51+105));
		points.add(new Point(403,51+105));
		sections.add(points);
		line=new GuiLine(sections,ZAND2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,100+105));
		points.add(new Point(403,100+105));
		sections.add(points);
		line=new GuiLine(sections,ZAND3.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(396,114+105));
		points.add(new Point(399,114+105));
		points.add(new Point(399,111+105));
		points.add(new Point(403,111+105));
		sections.add(points);
		line=new GuiLine(sections,ZAND4.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,56+105));
		points.add(new Point(429,56+105));
		sections.add(points);
		line=new GuiLine(sections,ZOR1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,105+105));
		points.add(new Point(429,105+105));
		sections.add(points);
		line=new GuiLine(sections,ZOR2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(483,56+105));
		points.add(new Point(490,56+105));
		sections.add(points);
		line=new GuiLine(sections,ZRSFF.getOut(0));
		gui.addLine(line);

		//////////////////////////////////////////////////////////////////////////////////
		
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,42+211));
		points.add(new Point(374,42+211));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldC());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(368,43+211));
		points.add(new Point(368,109+211));
		points.add(new Point(374,109+211));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldC());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,81+211));
		points.add(new Point(361,81+211));
		points.add(new Point(361,53+211));
		points.add(new Point(374,53+211));
		sections.add(points);
		line=new GuiLine(sections,Exec3.C());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(361,82+211));
		points.add(new Point(361,119+211));
		points.add(new Point(369,119+211));
		sections.add(points);
		line=new GuiLine(sections,Exec3.C());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(268,105+211));
		points.add(new Point(328,105+211));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(2));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(319,104+211));
		points.add(new Point(319,67+211));
		points.add(new Point(332,67+211));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(2));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,61+211));
		points.add(new Point(403,61+211));
		sections.add(points);
		line=new GuiLine(sections,CAND1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(397,47+211));
		points.add(new Point(399,47+211));
		points.add(new Point(399,51+211));
		points.add(new Point(403,51+211));
		sections.add(points);
		line=new GuiLine(sections,CAND2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,100+211));
		points.add(new Point(403,100+211));
		sections.add(points);
		line=new GuiLine(sections,CAND3.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(396,114+211));
		points.add(new Point(399,114+211));
		points.add(new Point(399,111+211));
		points.add(new Point(403,111+211));
		sections.add(points);
		line=new GuiLine(sections,CAND4.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,56+211));
		points.add(new Point(429,56+211));
		sections.add(points);
		line=new GuiLine(sections,COR1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,105+211));
		points.add(new Point(429,105+211));
		sections.add(points);
		line=new GuiLine(sections,COR2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(483,56+211));
		points.add(new Point(490,56+211));
		sections.add(points);
		line=new GuiLine(sections,CRSFF.getOut(0));
		gui.addLine(line);
		
		////////////////////////////////////////////////////////

		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,42+316));
		points.add(new Point(374,42+316));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldV());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(368,43+316));
		points.add(new Point(368,109+316));
		points.add(new Point(374,109+316));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldV());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,81+316));
		points.add(new Point(361,81+316));
		points.add(new Point(361,53+316));
		points.add(new Point(374,53+316));
		sections.add(points);
		line=new GuiLine(sections,Exec3.V());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(361,82+316));
		points.add(new Point(361,119+316));
		points.add(new Point(369,119+316));
		sections.add(points);
		line=new GuiLine(sections,Exec3.V());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(268,105+316));
		points.add(new Point(328,105+316));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(3));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(319,104+316));
		points.add(new Point(319,67+316));
		points.add(new Point(332,67+316));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(3));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,61+316));
		points.add(new Point(403,61+316));
		sections.add(points);
		line=new GuiLine(sections,VAND1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(397,47+316));
		points.add(new Point(399,47+316));
		points.add(new Point(399,51+316));
		points.add(new Point(403,51+316));
		sections.add(points);
		line=new GuiLine(sections,VAND2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,100+316));
		points.add(new Point(403,100+316));
		sections.add(points);
		line=new GuiLine(sections,VAND3.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(396,114+316));
		points.add(new Point(399,114+316));
		points.add(new Point(399,111+316));
		points.add(new Point(403,111+316));
		sections.add(points);
		line=new GuiLine(sections,VAND4.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,56+316));
		points.add(new Point(429,56+316));
		sections.add(points);
		line=new GuiLine(sections,VOR1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,105+316));
		points.add(new Point(429,105+316));
		sections.add(points);
		line=new GuiLine(sections,VOR2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(483,56+316));
		points.add(new Point(490,56+316));
		sections.add(points);
		line=new GuiLine(sections,VRSFF.getOut(0));
		gui.addLine(line);
		
		///////////////////////////////////////////////////////
		
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,42+422));
		points.add(new Point(374,42+422));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(368,43+422));
		points.add(new Point(368,109+422));
		points.add(new Point(374,109+422));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,81+422));
		points.add(new Point(361,81+422));
		points.add(new Point(361,53+422));
		points.add(new Point(374,53+422));
		sections.add(points);
		line=new GuiLine(sections,Intr2.prl0());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(361,82+422));
		points.add(new Point(361,119+422));
		points.add(new Point(369,119+422));
		sections.add(points);
		line=new GuiLine(sections,Intr2.prl0());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(268,105+422));
		points.add(new Point(328,105+422));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(4));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(319,104+422));
		points.add(new Point(319,67+422));
		points.add(new Point(332,67+422));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(4));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,61+422));
		points.add(new Point(403,61+422));
		sections.add(points);
		line=new GuiLine(sections,L0AND1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(397,47+422));
		points.add(new Point(399,47+422));
		points.add(new Point(399,51+422));
		points.add(new Point(403,51+422));
		sections.add(points);
		line=new GuiLine(sections,L0AND2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,100+422));
		points.add(new Point(403,100+422));
		sections.add(points);
		line=new GuiLine(sections,L0AND3.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(396,114+422));
		points.add(new Point(399,114+422));
		points.add(new Point(399,111+422));
		points.add(new Point(403,111+422));
		sections.add(points);
		line=new GuiLine(sections,L0AND4.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,56+422));
		points.add(new Point(429,56+422));
		sections.add(points);
		line=new GuiLine(sections,L0OR1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,105+422));
		points.add(new Point(429,105+422));
		sections.add(points);
		line=new GuiLine(sections,L0OR2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(483,56+422));
		points.add(new Point(490,56+422));
		sections.add(points);
		line=new GuiLine(sections,L0RSFF.getOut(0));
		gui.addLine(line);
		
		///////////////////////////////////////////////////////////
		
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,42+527));
		points.add(new Point(374,42+527));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(368,43+527));
		points.add(new Point(368,109+527));
		points.add(new Point(374,109+527));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,81+527));
		points.add(new Point(361,81+527));
		points.add(new Point(361,53+527));
		points.add(new Point(374,53+527));
		sections.add(points);
		line=new GuiLine(sections,Intr2.prl1());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(361,82+527));
		points.add(new Point(361,119+527));
		points.add(new Point(369,119+527));
		sections.add(points);
		line=new GuiLine(sections,Intr2.prl1());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(268,105+527));
		points.add(new Point(328,105+527));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(5));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(319,104+527));
		points.add(new Point(319,67+527));
		points.add(new Point(332,67+527));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(6));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,61+527));
		points.add(new Point(403,61+527));
		sections.add(points);
		line=new GuiLine(sections,L1AND1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(397,47+527));
		points.add(new Point(399,47+527));
		points.add(new Point(399,51+527));
		points.add(new Point(403,51+527));
		sections.add(points);
		line=new GuiLine(sections,L1AND2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,100+527));
		points.add(new Point(403,100+527));
		sections.add(points);
		line=new GuiLine(sections,L1AND3.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(396,114+527));
		points.add(new Point(399,114+527));
		points.add(new Point(399,111+527));
		points.add(new Point(403,111+527));
		sections.add(points);
		line=new GuiLine(sections,L1AND4.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,56+527));
		points.add(new Point(429,56+527));
		sections.add(points);
		line=new GuiLine(sections,L1OR1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,105+527));
		points.add(new Point(429,105+527));
		sections.add(points);
		line=new GuiLine(sections,L1OR2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(483,56+527));
		points.add(new Point(490,56+527));
		sections.add(points);
		line=new GuiLine(sections,L1RSFF.getOut(0));
		gui.addLine(line);
		
		////////////////////////////////////////////////////////////
		
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,42+527+105));
		points.add(new Point(374,42+527+105));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(368,43+527+105));
		points.add(new Point(368,109+527+105));
		points.add(new Point(374,109+527+105));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(312,81+527+105));
		points.add(new Point(361,81+527+105));
		points.add(new Point(361,53+527+105));
		points.add(new Point(374,53+527+105));
		sections.add(points);
		line=new GuiLine(sections,Intr2.prl2());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(361,82+527+105));
		points.add(new Point(361,119+527+105));
		points.add(new Point(369,119+527+105));
		sections.add(points);
		line=new GuiLine(sections,Intr2.prl2());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(268,105+527+105));
		points.add(new Point(328,105+527+105));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(6));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(319,104+527+105));
		points.add(new Point(319,67+527+105));
		points.add(new Point(332,67+527+105));
		sections.add(points);
		line=new GuiLine(sections,IBUSBits.getOut(7));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,61+527+105));
		points.add(new Point(403,61+527+105));
		sections.add(points);
		line=new GuiLine(sections,L2AND1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(397,47+527+105));
		points.add(new Point(399,47+527+105));
		points.add(new Point(399,51+527+105));
		points.add(new Point(403,51+527+105));
		sections.add(points);
		line=new GuiLine(sections,L2AND2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(355,100+527+105));
		points.add(new Point(403,100+527+105));
		sections.add(points);
		line=new GuiLine(sections,L2AND3.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(396,114+527+105));
		points.add(new Point(399,114+527+105));
		points.add(new Point(399,111+527+105));
		points.add(new Point(403,111+527+105));
		sections.add(points);
		line=new GuiLine(sections,L2AND4.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,56+527+105));
		points.add(new Point(429,56+527+105));
		sections.add(points);
		line=new GuiLine(sections,L2OR1.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(424,105+527+105));
		points.add(new Point(429,105+527+105));
		sections.add(points);
		line=new GuiLine(sections,L2OR2.getOut(0));
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(483,56+527+105));
		points.add(new Point(490,56+527+105));
		sections.add(points);
		line=new GuiLine(sections,L2RSFF.getOut(0));
		gui.addLine(line);
		
		///////////////////////////////////////////////////
		
		// 
		// 
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(326,23));
		points.add(new Point(326,727));
		points.add(new Point(332,727));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,688));
		points.add(new Point(332,688));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,621));
		points.add(new Point(332,621));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,582));
		points.add(new Point(332,582));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,516));
		points.add(new Point(332,516));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,477));
		points.add(new Point(332,477));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,410));
		points.add(new Point(332,410));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,372));
		points.add(new Point(332,372));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,305));
		points.add(new Point(332,305));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,266));
		points.add(new Point(332,266));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,199));
		points.add(new Point(332,199));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,161));
		points.add(new Point(332,161));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,94));
		points.add(new Point(332,94));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		sections=new ArrayList<ArrayList<Point>>();
		points=new ArrayList<Point>();
		points.add(new Point(327,56));
		points.add(new Point(332,56));
		sections.add(points);
		line=new GuiLine(sections,UpravOper.ldPSWL());
		gui.addLine(line);

		//
		//
		
		gui.addLabel(new GuiLabel(240, 358, Bus.IBUS()));

		
	}
	
	///////////////////////////////////////////////////////
	
	
	
	/////////////
	/////////////
	/////////////
	
	public static void init() {
		
		////
		IBUSBits = new IntToBools(16, 16);
		////
		
		IAND1 = new AND();
		IOR1 = new OR();
		INOT = new NOT();
		IAND2 = new AND();
		IOR2 = new OR();
		IRSFF = new RSFF("I");

		TAND1 = new AND();
		TOR1 = new OR();
		TNOT = new NOT();
		TAND2 = new AND();
		TOR2 = new OR();
		TRSFF = new RSFF("T");

		NAND1 = new AND();
		NAND2 = new AND();
		NOR1 = new OR();
		NNOT1 = new NOT();
		NAND3 = new AND();
		NNOT2 = new NOT();
		NAND4 = new AND();
		NOR2 = new OR();
		NRSFF = new RSFF("N");

		ZAND1 = new AND();
		ZAND2 = new AND();
		ZOR1 = new OR();
		ZNOT1 = new NOT();
		ZAND3 = new AND();
		ZNOT2 = new NOT();
		ZAND4 = new AND();
		ZOR2 = new OR();
		ZRSFF = new RSFF("Z");

		CAND1 = new AND();
		CAND2 = new AND();
		COR1 = new OR();
		CNOT1 = new NOT();
		CAND3 = new AND();
		CNOT2 = new NOT();
		CAND4 = new AND();
		COR2 = new OR();
		CRSFF = new RSFF("C");

		VAND1 = new AND();
		VAND2 = new AND();
		VOR1 = new OR();
		VNOT1 = new NOT();
		VAND3 = new AND();
		VNOT2 = new NOT();
		VAND4 = new AND();
		VOR2 = new OR();
		VRSFF = new RSFF("V");

		L0AND1 = new AND();
		L0AND2 = new AND();
		L0OR1 = new OR();
		L0NOT1 = new NOT();
		L0AND3 = new AND();
		L0NOT2 = new NOT();
		L0AND4 = new AND();
		L0OR2 = new OR();
		L0RSFF = new RSFF("L0");

		L1AND1 = new AND();
		L1AND2 = new AND();
		L1OR1 = new OR();
		L1NOT1 = new NOT();
		L1AND3 = new AND();
		L1NOT2 = new NOT();
		L1AND4 = new AND();
		L1OR2 = new OR();
		L1RSFF = new RSFF("L1");
		
		L2AND1 = new AND();
		L2AND2 = new AND();
		L2OR1 = new OR();
		L2NOT1 = new NOT();
		L2AND3 = new AND();
		L2NOT2 = new NOT();
		L2AND4 = new AND();
		L2OR2 = new OR();
		L2RSFF = new RSFF("L2");

		PSW_H = new BoolsToInt(8, 8);
		PSW_L = new BoolsToInt(8, 8);
		
		PSWHout = new TSB();
		PSWHout.getOut(0).setNumOfLines(8);
		PSWLout = new TSB();
		PSWLout.getOut(0).setNumOfLines(8);

		STARTRSFF = new RSFF("START");
		not_start = new NOT();
		
	}
	
	public static void connect() {
		
		////
		IBUSBits.setInputPin(0, Bus.IBUS());
		////

		TAND1.setInputPin(0, UpravOper.ldPSWH());
		TAND1.setInputPin(1, IBUSBits.getOut(6));
		TOR1.setInputPin(0, UpravOper.stPSWT());
		TOR1.setInputPin(1, TAND1.getOut(0));
		TNOT.setInputPin(0, IBUSBits.getOut(6));
		TAND2.setInputPin(0, UpravOper.ldPSWH());
		TAND2.setInputPin(1, TNOT.getOut(0));
		TOR2.setInputPin(0, TAND2.getOut(0));
		TOR2.setInputPin(1, UpravOper.clPSWT());
		TRSFF.setPinE(new Pin(true));
		TRSFF.setPinClear(new Pin(false));
		TRSFF.setPinS(TOR1.getOut(0));
		TRSFF.setPinR(TOR2.getOut(0));
		
		IAND1.setInputPin(0, UpravOper.ldPSWH());
		IAND1.setInputPin(1, IBUSBits.getOut(7));
		IOR1.setInputPin(0, UpravOper.stPSWI());
		IOR1.setInputPin(1, IAND1.getOut(0));
		INOT.setInputPin(0, IBUSBits.getOut(7));
		IAND2.setInputPin(0, UpravOper.ldPSWH());
		IAND2.setInputPin(1, INOT.getOut(0));
		IOR2.setInputPin(0, IAND2.getOut(0));
		IOR2.setInputPin(1, UpravOper.clPSWI());
		IRSFF.setPinE(new Pin(true));
		IRSFF.setPinClear(new Pin(false));
		IRSFF.setPinS(IOR1.getOut(0));
		IRSFF.setPinR(IOR2.getOut(0));

		NAND1.setInputPin(0, UpravOper.ldPSWL());
		NAND1.setInputPin(1, IBUSBits.getOut(0));
		NAND2.setInputPin(0, UpravOper.ldN());
		NAND2.setInputPin(1, Exec3.N());
		NOR1.setInputPin(0, NAND2.getOut(0));
		NOR1.setInputPin(1, NAND1.getOut(0));
		NNOT1.setInputPin(0, IBUSBits.getOut(0));
		NAND3.setInputPin(0, UpravOper.ldPSWL());
		NAND3.setInputPin(1, NNOT1.getOut(0));
		NNOT2.setInputPin(0, Exec3.N());
		NAND4.setInputPin(0, UpravOper.ldN());
		NAND4.setInputPin(1, NNOT2.getOut(0));
		NOR2.setInputPin(0, NAND3.getOut(0));
		NOR2.setInputPin(1, NAND4.getOut(0));
		NRSFF.setPinE(new Pin(true));
		NRSFF.setPinClear(new Pin(false));
		NRSFF.setPinS(NOR1.getOut(0));
		NRSFF.setPinR(NOR2.getOut(0));

		ZAND1.setInputPin(0, UpravOper.ldPSWL());
		ZAND1.setInputPin(1, IBUSBits.getOut(1));
		ZAND2.setInputPin(0, UpravOper.ldZ());
		ZAND2.setInputPin(1, Exec3.Z());
		ZOR1.setInputPin(0, ZAND2.getOut(0));
		ZOR1.setInputPin(1, ZAND1.getOut(0));
		ZNOT1.setInputPin(0, IBUSBits.getOut(1));
		ZAND3.setInputPin(0, UpravOper.ldPSWL());
		ZAND3.setInputPin(1, ZNOT1.getOut(0));
		ZNOT2.setInputPin(0, Exec3.Z());
		ZAND4.setInputPin(0, UpravOper.ldZ());
		ZAND4.setInputPin(1, ZNOT2.getOut(0));
		ZOR2.setInputPin(0, ZAND3.getOut(0));
		ZOR2.setInputPin(1, ZAND4.getOut(0));
		ZRSFF.setPinE(new Pin(true));
		ZRSFF.setPinClear(new Pin(false));
		ZRSFF.setPinS(ZOR1.getOut(0));
		ZRSFF.setPinR(ZOR2.getOut(0));

		CAND1.setInputPin(0, UpravOper.ldPSWL());
		CAND1.setInputPin(1, IBUSBits.getOut(2));
		CAND2.setInputPin(0, UpravOper.ldC());
		CAND2.setInputPin(1, Exec3.C());
		COR1.setInputPin(0, CAND2.getOut(0));
		COR1.setInputPin(1, CAND1.getOut(0));
		CNOT1.setInputPin(0, IBUSBits.getOut(2));
		CAND3.setInputPin(0, UpravOper.ldPSWL());
		CAND3.setInputPin(1, CNOT1.getOut(0));
		CNOT2.setInputPin(0, Exec3.C());
		CAND4.setInputPin(0, UpravOper.ldC());
		CAND4.setInputPin(1, CNOT2.getOut(0));
		COR2.setInputPin(0, CAND3.getOut(0));
		COR2.setInputPin(1, CAND4.getOut(0));
		CRSFF.setPinE(new Pin(true));
		CRSFF.setPinClear(new Pin(false));
		CRSFF.setPinS(COR1.getOut(0));
		CRSFF.setPinR(COR2.getOut(0));

		VAND1.setInputPin(0, UpravOper.ldPSWL());
		VAND1.setInputPin(1, IBUSBits.getOut(3));
		VAND2.setInputPin(0, UpravOper.ldV());
		VAND2.setInputPin(1, Exec3.V());
		VOR1.setInputPin(0, VAND2.getOut(0));
		VOR1.setInputPin(1, VAND1.getOut(0));
		VNOT1.setInputPin(0, IBUSBits.getOut(3));
		VAND3.setInputPin(0, UpravOper.ldPSWL());
		VAND3.setInputPin(1, VNOT1.getOut(0));
		VNOT2.setInputPin(0, Exec3.V());
		VAND4.setInputPin(0, UpravOper.ldV());
		VAND4.setInputPin(1, VNOT2.getOut(0));
		VOR2.setInputPin(0, VAND3.getOut(0));
		VOR2.setInputPin(1, VAND4.getOut(0));
		VRSFF.setPinE(new Pin(true));
		VRSFF.setPinClear(new Pin(false));
		VRSFF.setPinS(VOR1.getOut(0));
		VRSFF.setPinR(VOR2.getOut(0));

		L0AND1.setInputPin(0, UpravOper.ldPSWL());
		L0AND1.setInputPin(1, IBUSBits.getOut(4));
		L0AND2.setInputPin(0, UpravOper.ldL());
		L0AND2.setInputPin(1, Intr2.prl0());
		L0OR1.setInputPin(0, L0AND2.getOut(0));
		L0OR1.setInputPin(1, L0AND1.getOut(0));
		L0NOT1.setInputPin(0, IBUSBits.getOut(4));
		L0AND3.setInputPin(0, UpravOper.ldPSWL());
		L0AND3.setInputPin(1, L0NOT1.getOut(0));
		L0NOT2.setInputPin(0, Intr2.prl0());
		L0AND4.setInputPin(0, UpravOper.ldL());
		L0AND4.setInputPin(1, L0NOT2.getOut(0));
		L0OR2.setInputPin(0, L0AND3.getOut(0));
		L0OR2.setInputPin(1, L0AND4.getOut(0));
		L0RSFF.setPinE(new Pin(true));
		L0RSFF.setPinClear(new Pin(false));
		L0RSFF.setPinS(L0OR1.getOut(0));
		L0RSFF.setPinR(L0OR2.getOut(0));

		L1AND1.setInputPin(0, UpravOper.ldPSWL());
		L1AND1.setInputPin(1, IBUSBits.getOut(5));
		L1AND2.setInputPin(0, UpravOper.ldL());
		L1AND2.setInputPin(1, Intr2.prl1());
		L1OR1.setInputPin(0, L1AND2.getOut(0));
		L1OR1.setInputPin(1, L1AND1.getOut(0));
		L1NOT1.setInputPin(0, IBUSBits.getOut(5));
		L1AND3.setInputPin(0, UpravOper.ldPSWL());
		L1AND3.setInputPin(1, L1NOT1.getOut(0));
		L1NOT2.setInputPin(0, Intr2.prl1());
		L1AND4.setInputPin(0, UpravOper.ldL());
		L1AND4.setInputPin(1, L1NOT2.getOut(0));
		L1OR2.setInputPin(0, L1AND3.getOut(0));
		L1OR2.setInputPin(1, L1AND4.getOut(0));
		L1RSFF.setPinE(new Pin(true));
		L1RSFF.setPinClear(new Pin(false));
		L1RSFF.setPinS(L1OR1.getOut(0));
		L1RSFF.setPinR(L1OR2.getOut(0));
		
		L2AND1.setInputPin(0, UpravOper.ldPSWL());
		L2AND1.setInputPin(1, IBUSBits.getOut(6));
		L2AND2.setInputPin(0, UpravOper.ldL());
		L2AND2.setInputPin(1, Intr2.prl2());
		L2OR1.setInputPin(0, L2AND2.getOut(0));
		L2OR1.setInputPin(1, L2AND1.getOut(0));
		L2NOT1.setInputPin(0, IBUSBits.getOut(6));
		L2AND3.setInputPin(0, UpravOper.ldPSWL());
		L2AND3.setInputPin(1, L2NOT1.getOut(0));
		L2NOT2.setInputPin(0, Intr2.prl2());
		L2AND4.setInputPin(0, UpravOper.ldL());
		L2AND4.setInputPin(1, L2NOT2.getOut(0));
		L2OR2.setInputPin(0, L2AND3.getOut(0));
		L2OR2.setInputPin(1, L2AND4.getOut(0));
		L2RSFF.setPinE(new Pin(true));
		L2RSFF.setPinClear(new Pin(false));
		L2RSFF.setPinS(L2OR1.getOut(0));
		L2RSFF.setPinR(L2OR2.getOut(0));

		PSW_L.setInputPin(0, NRSFF.getOut(0));
		PSW_L.setInputPin(1, ZRSFF.getOut(0));
		PSW_L.setInputPin(2, CRSFF.getOut(0));
		PSW_L.setInputPin(3, VRSFF.getOut(0));
		PSW_L.setInputPin(4, L0RSFF.getOut(0));
		PSW_L.setInputPin(5, L1RSFF.getOut(0));
		PSW_L.setInputPin(6, L2RSFF.getOut(0));
		PSW_L.setInputPin(7, new Pin(false));
		
		for (int i = 0; i < 6; i++) {
			PSW_H.setInputPin(i, new Pin(false));
		}
		PSW_H.setInputPin(6, TRSFF.getOut(0));
		PSW_H.setInputPin(7, IRSFF.getOut(0));

		// TSB PSWHout, PSWLout;
		
		PSWHout.setInputPin(0, PSW_H.getOut(0));
		PSWHout.setCtrl(UpravOper.PSWHout());
		Bus.addOnIBUS(PSWHout.getOut(0));
		
		PSWLout.setInputPin(0, PSW_L.getOut(0));
		PSWLout.setCtrl(UpravOper.PSWLout());
		Bus.addOnIBUS(PSWLout.getOut(0));

		
		STARTRSFF.setInputPin(0, new Pin(false));
		STARTRSFF.setInputPin(1, UpravOper.clSTART()); // izmenjeno
		//STARTRSFF.getOut(0).setBoolVal(true); 	//na pocetku setovan izlaz START na true
												//nema vise potrebe za STSTART i posebnim setovanjem izlaza RSFF
		STARTRSFF.setInit(true);

		not_start.setInputPin(0, STARTRSFF.getOut(0));
	}
	
	
	public static Pin PSWI() {
		return IRSFF.getOut(0);
	}

	public static Pin PSWT() {
		return TRSFF.getOut(0);
	}

	public static Pin PSWN() {
		return NRSFF.getOut(0);
	}

	public static Pin PSWZ() {
		return ZRSFF.getOut(0);
	}

	public static Pin PSWC() {
		return CRSFF.getOut(0);
	}

	public static Pin PSWV() {
		return VRSFF.getOut(0);
	}

	public static Pin PSWL0() {
		return L0RSFF.getOut(0);
	}

	public static Pin PSWL1() {
		return L1RSFF.getOut(0);
	}
	
	public static Pin PSWL2() {
		return L2RSFF.getOut(0);
	}

	public static Pin START() {
		return STARTRSFF.getOut(0);
	}

	public static Pin not_start() {
		return not_start.getOut(0);
	}
	
	public static void ispisiFlegove() {
		System.out.println("\n Flegovi:" + " PSWI=" + IRSFF.getOut(0).getBoolVal() + " PSWT=" + TRSFF.getOut(0).getBoolVal() + " PSWN=" + NRSFF.getOut(0).getBoolVal() 
				+ " PSWZ=" + ZRSFF.getOut(0).getBoolVal() + " PSWC=" + CRSFF.getOut(0).getBoolVal() + " PSWV=" + VRSFF.getOut(0).getBoolVal() + " PSWL0=" + L0RSFF.getOut(0).getBoolVal() 
				+ " PSWL1=" + L1RSFF.getOut(0).getBoolVal() + " PSWL2=" + L2RSFF.getOut(0).getBoolVal() );
	}

}
